<?php
session_start();
$id = $_POST['xId'];
$st = $_POST['xstatus'];

include("conexion.php");
	
$var = new conexion();
$var->conectarse();

if($st != 'Z' && $st != 'X')
{
    switch($st)
    {
        case "E":
            $_search = "Update polimeros Set estado = '".$st."', EnFacturacion ='F' Where id_polimero = ".$id;
            $resu = mysql_query($_search);
            break;
            
        case "Q":
            $_search = "Update polimeros Set EnFacturacion ='A' Where id_polimero = ".$id;
            $resu = mysql_query($_search);
            break;
        
        case "R":
        case "S":
            $_search = "Update polimeros Set EnFacturacion ='".$st."' Where id_polimero = ".$id;
            $resu = mysql_query($_search);
            break;
        
        default:
            $_search = "Update polimeros Set estado = '".$st."' Where id_polimero = ".$id;
            $resu = mysql_query($_search);
            break;
    }
    
}
else
{
    if($st == 'Z')
    {
        $_search = "Update polimeros Set standBy = 1 Where id_polimero = ".$id;
    }
    else
    {
        $_search = "Update polimeros Set standBy = 0 Where id_polimero = ".$id;
    }
    $resu = mysql_query($_search);
}

$_insert = "Insert tbl_log_polimeros (polimeroId, polimeroEstado, usuarioId, logFecha, observacion) values ";
$_insert.= "(".$id.", '".$st."', ".$_SESSION['id_usuario'].", NOW(), '')"; 

$resu = mysql_query($_insert);

echo json_encode(1);
?>